package com.yaoxuguang.concurrence.volatilePackage;

/**
 * @author yaoxuguang
 * @Title: yao-interview
 * @Package com.yaoxuguang.concurrence.volatilePackage
 * @Description: volatile非原子性
 * @date 2018年12月18日16:14
 */
public class VolatileDemo extends Thread{
//    volatile private static int count;
     private static int count;
//    private static void addCount(){
    synchronized private static void addCount(){
        for (int i = 0; i < 100; i++) {
            //不是原子性操作
            count++;
        }
        System.out.println("count="+count);
    }

    @Override
    public void run() {
        addCount();
    }
}
